;
(function($, window, undefined) {
    var rss = window.rss;
    var localInfo = window.localInfo;
    var reqClientType = localInfo.reqClientType;
    var loginUserName = localInfo.loginUserName;
    var openAuthenDialog = window.openAuthenDialog;
    var getAuthCode = window.getAuthCode;
    var getAccountInfo = window.getAccountInfo;
    var checkAuthCodeInput = window.checkAuthCodeInput;
    var isVerifySecEmail = false; // 激活安全邮箱还是激活邮箱，这两个是公用一个对话框
    var currentVerifyAccount;// 当前需要激活的账号
    var currentVerifyAnonyAccount;// 当前需要激活的账号的匿名账号
    

    ec.ready(function() {
    	mobileValidator();
    	
        $("#bindEmailBtn").click(function() {
            var accountType = localInfo.accountType;
            if (accountType == 0) {
                var param = {
                    desc : '',
                    lBtnTxt : rss.cancel_btn,
                    rBtnTxt : rss.verify,
                    queryCond : loginUserName,
                    optType : "bind",
                    callbackFn : bindEmail
                };
                openAuthenDialog(param);
            } else {
                var param = {
                    desc : rss.secAccountBindTip,
                    lBtnTxt : rss.cancel_btn,
                    rBtnTxt : rss.next_btn,
                    queryCond : loginUserName,
                    optType : "bind",
                    callbackFn : bindEmail
                };
                openAuthenDialog(param);
            }

        });

        $("#bindPhoneBtn").click(function() {
            var accountType = localInfo.accountType;
            if (accountType == 0) {
                var param = {
                    desc : '',
                    lBtnTxt : rss.cancel_btn,
                    rBtnTxt : rss.verify,
                    queryCond : loginUserName,
                    optType : "bind",
                    callbackFn : bindPhone
                };
                openAuthenDialog(param);
            } else {
                var param = {
                    desc : rss.secAccountBindTip,
                    lBtnTxt : rss.cancel_btn,
                    rBtnTxt : rss.next_btn,
                    queryCond : loginUserName,
                    optType : "bind",
                    callbackFn : bindPhone
                };
                openAuthenDialog(param);
            }

        });

        $("#changeEmailBtn").click(function() {
            showUserNoticeDialog('changeEmail');
        });
        
        $("#changeEmailBtn_0").click(function() {
            showUserNoticeDialog('changeEmail_0');
        });
        
        $("#changeEmailBtn_1").click(function() {
            showUserNoticeDialog('changeEmail_1');
        });
        
        $("#changeEmailBtn_2").click(function() {
            showUserNoticeDialog('changeEmail_2');
        });
        
        $("#changeEmailBtn_3").click(function() {
            showUserNoticeDialog('changeEmail_3');
        });
        
        $("#changeEmailBtn_4").click(function() {
            showUserNoticeDialog('changeEmail_4');
        });


        $("#changePhoneBtn").click(function() {
            showUserNoticeDialog('changePhone');
        });
        
        $("#changePhoneBtn_0").click(function() {
            showUserNoticeDialog('changePhone_0');
        });
        
        $("#changePhoneBtn_1").click(function() {
            showUserNoticeDialog('changePhone_1');
        });
        
        $("#changePhoneBtn_2").click(function() {
            showUserNoticeDialog('changePhone_2');
        });
        
        $("#changePhoneBtn_3").click(function() {
            showUserNoticeDialog('changePhone_3');
        });
        
        $("#changePhoneBtn_4").click(function() {
            showUserNoticeDialog('changePhone_4');
        });

        $("#unbindEmailBtn").click(function() {
            showUserNoticeDialog('unbindEmail');
        });
        
        $("#unbindEmailBtn_0").click(function() {
            showUserNoticeDialog('unbindEmail_0');
        });
        
        $("#unbindEmailBtn_1").click(function() {
            showUserNoticeDialog('unbindEmail_1');
        });
        
        $("#unbindEmailBtn_2").click(function() {
            showUserNoticeDialog('unbindEmail_2');
        });
        
        $("#unbindEmailBtn_3").click(function() {
            showUserNoticeDialog('unbindEmail_3');
        });
        
        $("#unbindEmailBtn_4").click(function() {
            showUserNoticeDialog('unbindEmail_4');
        });

        $("#unbindPhoneBtn").click(function() {
            showUserNoticeDialog('unbindPhone');
        });
    
        $("#unbindPhoneBtn_0").click(function() {
            showUserNoticeDialog('unbindPhone_0');
        });
        
        $("#unbindPhoneBtn_1").click(function() {
            showUserNoticeDialog('unbindPhone_1');
        });
        
        $("#unbindPhoneBtn_2").click(function() {
            showUserNoticeDialog('unbindPhone_2');
        });
        
        $("#unbindPhoneBtn_3").click(function() {
            showUserNoticeDialog('unbindPhone_3');
        });
        
        $("#unbindPhoneBtn_4").click(function() {
            showUserNoticeDialog('unbindPhone_4');
        });
    
        
        
    var verifyPhoneBtnArr=$("span[id^='verifyPhoneBtn_']");
    
    for(var i=0;i<verifyPhoneBtnArr.length;i++)
    {
    	var btnID=verifyPhoneBtnArr[i].id;
    	var index=null
    	
    	if(btnID.indexOf("_")>=0)
    	{
    		index=btnID.split("_")[1];
    	}
    	
    	$("#"+btnID).unbind("click");
    	
    	$(document).on("click", "#"+btnID, function(e) {
        	e.stopPropagation();
        	
        	
            var targetId = e.target.id;
            
            var targetIndex = "0";
        	//  认定index必然不会为空
        	if(targetId.indexOf("_")>=0)
        	{
        		targetIndex=targetId.split("_")[1];
        	}
        	
        	currentVerifyAccount = $("#phoneVal_"+targetIndex).text();
        	currentVerifyAnonyAccount = $("#phoneVal_"+targetIndex).attr('anonyAccount');
        	
        	if (isActiveAccount(currentVerifyAccount, 2)) {
        		showError($("#verifyPhoneTips_"+targetIndex), rss.phoneActivated);
                return;
        	}
        	
        	var phoneVal=$("#phoneVal_"+targetIndex).text();
        	
        	var htmlStr="";
        	htmlStr=htmlStr+'<p class="inptips2">' +rss.uc_verify_phone_tip.format(getExpressPhone(phoneVal))+ '</p>';
        	htmlStr=htmlStr+'<div id="unactived_phone"></div>';
        	htmlStr=htmlStr+'<div class="dbtn2 sbtn r" act="getVerificationCode" intervaltime="60"><span>' + rss.getAuthCode + '</span><p id="get_authcode_error_info"></p></div>';
        	htmlStr=htmlStr+'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.smsAuthCode+ '"></div><p id="auth_code_error_info"></p>';
        	
        	
        	
        	var option={
        			title:rss.uc_verify_phone,
        			btnRight:{
        				text:rss.verify,
        				fn:function(){
        					// 激活手机账号
        					
        					var self=this;
        					
        					if(!ec.form.validator($("#security_account_verify_code"), true))
        					{
        						return;
        					}
        					
        					// 验证码初步合规之后，调用后台
        					var smsAuthCode=$("#security_account_verify_code").val();
        					activatePhoneAccount(smsAuthCode,function(){
        						self.hide();
        						showTipDialog(rss.setSuccess, rss.close_btn, rss.uc_common_phone_use_tip,function() {
    								window.location.reload();
    							});
        					});
        				}
        			},
        			btnLeft:{
        				text:rss.cancel_btn,
        				fn:function(){
        					
        				}
        			},
        			actions:{
        				getVerificationCode:function(){
        					
        					var self=this;
        					
        					if(checkAuthCodeBtnState(this.$dialog)){
        						
        						getAuthCodeForUnSMS(2,localInfo.phone, 0, function(ret) {
        							if (ret) {
        								authCodeCountDown(self.$dialog, rss.resend);
        							}
        						});
        						
        					}
        				}
        			},
        			html:htmlStr,
        			beforeAction:function(){
        				checkAuthCodeInput($("#security_account_verify_code"),"#auth_code_error_info");
        			}
        	};
        	
        	$("<div>").Dialog(option).Dialog("show");
        	//verifyPhone($("#emailVal").text());
        });
    }
    
    
    
    function activatePhoneAccount(authCode,callback)
    {
    	var params={
    		mobilePhone:currentVerifyAccount,// 激活手机，需要传入明文手机账号
    		reqClientType:localInfo.reqClientType,
    		smsAuthCode:authCode,
    		pageToken:localInfo.pageToken
    	};
    	
    	ajaxHandler("activateMsisdn",params,function(data){
    		if(data && data.isSuccess==1){
    			if(typeof callback == "function"){
    				callback();
    			}
    		}
    		else
    		{
    			
    			switch(data.errorCode){
	    			case '10000001':
				  	case '70001101':
	 				case '70001201':{
	 					showError($(".errortip"), rss.error_10000001);
	 					break;
	 				}
	 				case '70002039':{
	 					showError($(".errortip"), rss.error_70002039);
	 					break;
	 				}
	 				case '70001401': {
	 					showError($(".errortip"), rss.error_70001401);
	 					break;
	 				}
	 				case '70002001': {
	 					showError($(".errortip"), rss.error_70002001);
	 					break;
	 				}
	 				default:{
	 					showError($(".errortip"), rss.error_10000001);
	 					break;
	 				}
    			}	
    		}	
    		
    	},function(){},true,"json");
    }
    
    function activateSecPhoneAccount(authCode,callback)
    {
    	var params={
    		mobilePhone:currentVerifyAccount,
    		reqClientType:localInfo.reqClientType,
    		smsAuthCode:authCode,
    		pageToken:localInfo.pageToken
    	};
    	
    	ajaxHandler("activateMsisdn",params,function(data){
    		if(data && data.isSuccess==1){
    			if(typeof callback == "function"){
    				callback();
    			}
    		}
    		else
    		{
    			
    			switch(data.errorCode){
	    			case '10000001':
				  	case '70001101':
	 				case '70001201':{
	 					showError($(".errortip"), rss.error_10000001);
	 					break;
	 				}
	 				case '70002039':{
	 					showError($(".errortip"), rss.error_70002039);
	 					break;
	 				}
	 				case '70001401': {
	 					showError($(".errortip"), rss.error_70001401);
	 					break;
	 				}
	 				case '70002001': {
	 					showError($(".errortip"), rss.error_70002001);
	 					break;
	 				}
	 				default:{
	 					showError($(".errortip"), rss.error_10000001);
	 					break;
	 				}
    			}	
    		}	
    		
    	},function(){},true,"json");
    }
    
    var verifyEmailBtnArr=$("span[id^='verifyEmailBtn_']");
    
    for(var i=0;i<verifyEmailBtnArr.length;i++)
    {
    	
    	var btnID=verifyEmailBtnArr[i].id;
    	
    	var index=null;
    	
    	//  认定index必然不会为空
    	if(btnID.indexOf("_")>=0)
    	{
    		index=btnID.split("_")[1];
    	}
    	
    	$("#"+btnID).unbind("click");
    	$(document).on("click", "#"+btnID, function(e) {
            e.stopPropagation();
            
            // "verifyEmailBtn_2"
            var targetId = e.target.id;
            
            var targetIndex = "0";
        	//  认定index必然不会为空
        	if(targetId.indexOf("_")>=0)
        	{
        		targetIndex=targetId.split("_")[1];
        	}
        	
        	//var targetEmail=$("#emailVal_"+targetIndex).text();
        	
        	currentVerifyAccount = $("#emailVal_"+targetIndex).text();
        	currentVerifyAnonyAccount = $("#emailVal_"+targetIndex).attr('anonyAccount');
            
            if (isActiveAccount(currentVerifyAccount, 1)) {// 判断账号是否存在，需要传入匿名账号作为参数
            	showError($("#verifyEmailTips_"+targetIndex), rss.emailActivated);
                return;
            }
            
            verifyEmail(currentVerifyAnonyAccount);
            
            $("#iHaveVerifyBtn").on("click", function(e) {
                e.stopPropagation();
                checkEmailHasVerify(currentVerifyAccount, 1);
            });
        });
    }
    
        
    

    $(document).on("click", "#resendEmail", function(e) {
        e.stopPropagation();
        hideDialog($("#verifyEmailTipDialog"));

        if (isVerifySecEmail)
        {
        	// 验证安全邮箱
        	verifySecurityEmail(currentVerifyAnonyAccount);
        }
        else
        {
        	verifyEmail(currentVerifyAnonyAccount);
        }
    });

    $("#security_phone_auth_btn").click(function() {
    	currentVerifyAnonyAccount = localInfo.anonySecPhoneAcct;
    	currentVerifyAccount = localInfo.securityPhone;
    	
    	if (isActiveAccount(currentVerifyAccount, 6)) {
    		showError($("#security_phone_tip"), rss.phoneActivated);
            return;
    	}
    	
    	var phoneVal=$("#security_phone_text").text();
    	
    	var htmlStr="";
    	htmlStr=htmlStr+'<p class="inptips2">' +rss.uc_verify_phone_tip.format(getExpressPhone(phoneVal))+ '</p>';
    	htmlStr=htmlStr+'<div id="unactived_phone"></div>';
    	htmlStr=htmlStr+'<div class="dbtn2 sbtn r" act="getVerificationCode" intervaltime="60"><span>' + rss.getAuthCode + '</span><p id="get_authcode_error_info"></p></div>';
    	htmlStr=htmlStr+'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.smsAuthCode+ '"></div><p id="auth_code_error_info"></p>';
    	
    	var option={
    			title:rss.uc_verify_phone,
    			btnRight:{
    				text:rss.verify,
    				fn:function(){
    					// 激活手机账号
    					
    					var self=this;
    					
    					if(!ec.form.validator($("#security_account_verify_code"), true))
    					{
    						return;
    					}
    					
    					// 验证码初步合规之后，调用后台
    					var smsAuthCode=$("#security_account_verify_code").val();
    					activateSecPhoneAccount(smsAuthCode,function(){
    						self.hide();
    						showTipDialog(rss.setSuccess, rss.close_btn, rss.secPhoneUseTip,function() {
								window.location.reload();
							});
    					});
    				}
    			},
    			btnLeft:{
    				text:rss.cancel_btn,
    				fn:function(){
    					
    				}
    			},
    			actions:{
    				getVerificationCode:function(){
    					
    					var self=this;
    					
    					if(checkAuthCodeBtnState(this.$dialog)){
    						
    						if (localInfo.phone && localInfo.phone.length > 5)
    						{
        						getAuthCodeForUnSMS(2,localInfo.phone, 0, function(ret) {
        							if (ret) {
        								authCodeCountDown(self.$dialog, rss.resend);
        							}
        						}, localInfo.securityPhone, 6);
    						}
    						else
    						{
        						getAuthCodeForUnSMS(1,localInfo.email, 0, function(ret) {
        							if (ret) {
        								authCodeCountDown(self.$dialog, rss.resend);
        							}
        						}, localInfo.securityPhone, 6);
    						}
    						
    					}
    				}
    			},
    			html:htmlStr,
    			beforeAction:function(){
    				checkAuthCodeInput($("#security_account_verify_code"),"#auth_code_error_info");
    			}
    	};    
    	
    	$("<div>").Dialog(option).Dialog("show");
    });    
    
    $("#security_email_auth_btn").click(function() {
    	currentVerifyAnonyAccount = localInfo.anonySecEmailAcct;
    	 currentVerifyAccount = localInfo.securityEmail;
    	 
    	// 判断账号是否激活，需要使用匿名的账号
        if (isActiveAccount(currentVerifyAccount, 5)) {
        	showError($("#security_email_text"), rss.emailActivated);
            return;
        }
        
       
        verifySecurityEmail(currentVerifyAnonyAccount);
        
        $("#iHaveVerifyBtn").on("click", function(e) {
            checkEmailHasVerify(currentVerifyAccount, 5);
        });
        
    }); 
    
 });

    function bindPhone(param) {
        openPhoneDialog(param, rss.bindPhoneNumber, rss.bind_btn, 0);
    }

    function changePhone(param) {
        openPhoneDialog(param, rss.newPhoneNumber, rss.change_btn, 1);
    }

    function bindEmail(param) {
        openEmailDialog(param, rss.bindEmailAddr, rss.bind_btn, 0);
    }

    function changeEmail(param) {
        openEmailDialog(param, rss.newEmailAddr, rss.change_btn, 1);
    }

    function unbindAccount(param, callback) {
        delPhoneEamil(param, callback);
    }

    function delPhoneEamil(param, callback) {
        var obj = $.extend(param, {
            reqClientType : reqClientType,
            pageToken : localInfo.pageToken
        });

        ajaxHandler("delPhoneEmail", obj, function(data) {
            var flag = data.isSuccess;
            if (flag == "1") {
                callback();
                var isCurrentLoginAccount = data.isCurrentLoginAccount;
                var tips = "";
                if (isCurrentLoginAccount == "1") {
                    tips = rss.reloginTip;
                }
                showSuccessTipDialog(rss.unbindSeccess, tips, localInfo.successImgPath, function() {
                    if (isCurrentLoginAccount == "1") {
                        window.location.href = $("#logoutUrl").attr("href");
                    } else {
                        window.location.reload();
                    }
                });
            } else {
                if (data.errorCode == "10000001") {
                    showError($(".errortip"), rss.error_10000001);
                } else if (data.errorCode == "10000002") {
                    showError($(".errortip"), rss.error_10000002);
                } else if (data.errorCode == "10000004") {
                    showError($(".errortip"), rss.error_10000004);
                } else if (data.errorCode == "70001201") {
                    showError($(".errortip"), rss.error_70001201_2);
                } else if (data.errorCode == "70001401") {
                    showError($(".errortip"), rss.error_70001401);
                } else if (data.errorCode == "70002039") {
                    showError($(".errortip"), rss.error_70002039);
                } else if (data.errorCode == "70002057") {
                    showError($(".errortip"), rss.error_70002057_0);
                } else if (data.errorCode == "70002058") {
                    showError($(".errortip"), rss.error_70002058);
                } else if (data.errorCode == "70006006") {
                    showError($(".errortip"), rss.error_70006006);
                } else if (data.errorCode == "70002003") {
                    showError($(".errortip"), rss.error_70002003);
                } else if (data.errorCode == "70002001") {
                    showError($(".errortip"), rss.error_70002001);
                } else if (data.errorCode == "70002016") {
                    showError($(".errortip"), rss.error_70002016);
                } else if (data.errorCode == "70002053") {
                    showError($(".errortip"), rss.error_70002053);
                } else if (data.errorCode == "70002073") {
                    showError($(".errortip"), rss.error_70002073);
                } else if (data.errorCode == "70002043") {
                    showError($(".errortip"), rss.error_70002043);
                } else {
                    showError($(".errortip"), rss.unbindFailed);
                }
            }
        }, function(data) {
            showError($(".errortip"), rss.unbindFailed);
        }, true, "json");
    }

    function setPhoneEmail(oldAccObj, newAccObj, opType, callback) {
        var obj = {
            oldAccountType : oldAccObj.oldAccountType,
            oldUserAccount : oldAccObj.oldUserAccount,
            opType : opType,
            newAccountType : newAccObj.newAccountType,
            newUserAccount : newAccObj.newUserAccount,
            newAuthCode : newAccObj.newAuthCode,
            reqClientType : localInfo.reqClientType,
            "pageToken" : localInfo.pageToken
        };
        if (oldAccObj.oldAuthCode) {
            obj.oldAuthCode = oldAccObj.oldAuthCode;
        } else if (oldAccObj.password) {
            obj.password = oldAccObj.password;
        }

        ajaxHandler("setPhoneEmail", obj, function(data) {
            var flag = data.isSuccess;
            if (flag == "1") {
                var isCurrentLoginAccount = data.isCurrentLoginAccount;
                callback();
                if (opType == 0) {
                    if (obj.newAccountType == 1) {
                        showSuccessTipDialog("", rss.uc_common_email_addr_set_tip, localInfo.successEmailImgPath, function() {
                            window.location.reload();
                        });
                    } else if (obj.newAccountType == 2) {
                        showSuccessTipDialog("", rss.uc_common_phone_use_tip, localInfo.successPhoneImgPath, function() {
                            window.location.reload();
                        });
                    }

                } else if (opType == 1) {
                    if (obj.newAccountType == 1) {
                        var tips = rss.changeEmailSuccess;
                        if (isCurrentLoginAccount == "1") {
                            tips = rss.changeEmailOfLoginUserSuccess;
                        }
                        showSuccessTipDialog("", tips, localInfo.successEmailImgPath, function() {
                            if (isCurrentLoginAccount == "1") {
                                window.location.href = $("#logoutUrl").attr("href");
                            } else {
                                window.location.reload();
                            }

                        });
                    } else if (obj.newAccountType == 2) {
                        var tips = rss.changePhoneSuccess;
                        if (isCurrentLoginAccount == "1") {
                            tips = rss.changePhoneOfLoginuserSuccess;
                        }
                        showSuccessTipDialog("", tips, localInfo.successPhoneImgPath, function() {
                            if (isCurrentLoginAccount == 1) {
                                window.location.href = $("#logoutUrl").attr("href");
                            } else {
                                window.location.reload();
                            }
                        });
                    }
                }

            } else {
                if (data.errorCode == "10000001") {
                    showError($(".errortip"), rss.error_10000001);
                } else if (data.errorCode == "10000002") {
                    showError($(".errortip"), rss.error_10000002);
                } else if (data.errorCode == "10000004") {
                    showError($(".errortip"), rss.error_10000004);
                } else if (data.errorCode == "70001201") {
                    showError($(".errortip"), rss.error_70001201_2);
                } else if (data.errorCode == "70001401") {
                    showError($(".errortip"), rss.error_70001401);
                } else if (data.errorCode == "70002001") {
                    showError($(".errortip"), rss.error_70002001);
                } else if (data.errorCode == "70002002") {
                    showError($(".errortip"), rss.error_70002002);
                } else if (data.errorCode == "70002055") {
                    showError($(".errortip"), rss.error_70002055);
                } else if (data.errorCode == "70006006") {
                    showError($(".errortip"), rss.error_70006006);
                } else if (data.errorCode == "70002003") {
                    showError($(".errortip"), rss.error_70002003);
                } else if (data.errorCode == "70002057") {
                    showError($(".errortip"), rss.error_70002057_0);
                } else if (data.errorCode == "70002058") {
                    showError($(".errortip"), rss.error_70002058);
                } else if (data.errorCode == "70002039") {
                    showError($(".errortip"), rss.error_70002039);
                } else if (data.errorCode == "70002016") {
                    showError($(".errortip"), rss.error_70002016);
                } else if (data.errorCode == "70006007") {
                    showError($(".errortip"), rss.error_70006007_0);
                } else {
                    if (opType == 0) {
                        showError($(".errortip"), rss.bindAccountFailed);
                    } else {
                        showError($(".errortip"), rss.changeAccountFailed);
                    }
                }
            }
        }, function(data) {
            if (opType == 0) {
                showError($(".errortip"), rss.bindAccountFailed);
            } else {
                showError($(".errortip"), rss.changeAccountFailed);
            }
        }, true, "json");
    }

    function isActiveAccount(userAccount, accountType) {
        var isExist = false;
        getAccountInfo(loginUserName, 3, function(data) {
            if (data) {
                for (var i = 0; i < data.length; i++) {
                    var account = data[i];
                    if (account.userAccount == userAccount 
                    		&& accountType == account.accountType
                    		&& (account.accountType == 1 || account.accountType == 2 || account.accountType == 5 || account.accountType == 6) 
                    		&& account.accountState == 1) {
                    	isExist = true;
                        break;
                    }
                }
            }
        });
        return isExist;
    }

    function isExistAccount(userAccount, callbackFn) {
    	// 账号为空，不需要访问后台
    	if (!userAccount)
    	{
    		return;
    	}
    	
        var dataParms = {
            "userAccount" : userAccount,
            "pageToken" : localInfo.pageToken
        };
        ajaxHandler("isExsitUser", dataParms, function(data) {
            var isSuccess = data.isSuccess;
            var errorCode = data.errorCode;
            if (isSuccess == "1") {
                if (data.existAccountFlag >= 1) {
                    if (userAccount.indexOf("@") != -1) {
                        showError($("#authCodeError"), rss.emailAccountExists);
                    } else {
                        showError($("#authCodeError"), rss.phoneAccountExists);
                    }

                } else {
                    callbackFn();
                }
            } else {
                if (data.errorCode == "10000001") {
                    showError($("#authCodeError"), rss.error_10000001);
                } else if (data.errorCode == "10000002") {
                    showError($("#authCodeError"), rss.error_10000002);
                } else if (data.errorCode == "10000004") {
                    showError($("#authCodeError"), rss.error_10000004);
                } else if (data.errorCode == "10000507") { //其他站点帐号
                	showError($("#authCodeError"), rss.error_70002002);
                } else if (errorCode == "70001105") {
                    showError($("#authCodeError"), rss.systemBusy);
                } else {
                    showError($("#authCodeError"), rss.systemBusy);
                }
            }

        }, function() {
        }, false, "json");
    }

    function checkEmailHasVerify(userAccount, accountType) {
        if (isActiveAccount(userAccount, accountType)) {
            hideDialog($("#verifyEmailTipDialog"));
            window.location.reload();
        } else {
            showError($(".errortip"), rss.verifiedUnfinished);
        }
    }
    

    function verifyEmail(userAccount) {
        var param = {
            accountType : 1,
            userAccount : userAccount,
            reqClientType : reqClientType,
            email : userAccount,
            "pageToken" : localInfo.pageToken
        };
        ajaxHandler("getActivateEMailURL", param, function(data) {
            var flag = data.isSuccess;
            if (flag == "1") {
            	// 判断是否是激活安全邮箱
            	isVerifySecEmail = false;
                showDialog($("#verifyEmailTipDialog"));
                $("#verifyDialgEmail").text(userAccount);

            } else {
                if (data.errorCode == "10000001") {
                    showError($("#verifyEmailTips"), rss.error_10000001);
                } else if (data.errorCode == "10000002") {
                    showError($("#verifyEmailTips"), rss.error_10000002);
                } else if (data.errorCode == "10000004") {
                    showError($("#verifyEmailTips"), rss.error_10000004);
                } else if (data.errorCode == "70001102") {
                    showError($("#verifyEmailTips"), rss.error_70001102_2);
                } else if (data.errorCode == "70001104") {
                    showError($("#verifyEmailTips"), rss.error_70001104_3);
                } else if (data.errorCode == "70001201" || data.errorCode == "70002008") {
                    showError($("#verifyEmailTips"), rss.error_70001201_2);
                } else if (data.errorCode == "70001401") {
                    showError($("#verifyEmailTips"), rss.error_70001401);
                } else if (data.errorCode == "70002001") {
                    showError($("#verifyEmailTips"), rss.error_70002001);
                } else if (data.errorCode == "70002018") {
                    showError($("#verifyEmailTips"), rss.error_70002018);
                } else if (data.errorCode == "70002019") {
                    showError($("#verifyEmailTips"), rss.error_70002019);
                } else {
                    showError($("#verifyEmailTips"), rss.emailActivedFailed);
                }

            }
        }, function(data) {
            showError($("#verifyEmailTips"), rss.emailActivedFailed);
        }, true, "json");

    }

    function verifySecurityEmail(userAccount) {
    	var userAccountParam;
    	var accountTypeParam;
    	if (localInfo.anonyPhoneAcct)
    	{
    		userAccountParam = localInfo.anonyPhoneAcct;
    		accountTypeParam = "2";
    	}
    	else
    	{
    		userAccountParam = localInfo.anonyEmailAcct;
    		accountTypeParam = "1";
    	}
    	
        var param = {
            accountType : accountTypeParam,
            userAccount : userAccountParam,
            reqClientType : reqClientType,
            email : userAccount,
            "pageToken" : localInfo.pageToken
        };
        ajaxHandler("getActivateEMailURL", param, function(data) {
            var flag = data.isSuccess;
            if (flag == "1") {
            	// 判断是否是激活安全邮箱
            	isVerifySecEmail = true;
                showDialog($("#verifyEmailTipDialog"));
                $("#verifyDialgEmail").text(userAccount);

            } else {
                if (data.errorCode == "10000001") {
                    showError($("#security_email_text"), rss.error_10000001);
                } else if (data.errorCode == "10000002") {
                    showError($("#security_email_text"), rss.error_10000002);
                } else if (data.errorCode == "10000004") {
                    showError($("#security_email_text"), rss.error_10000004);
                } else if (data.errorCode == "70001102") {
                    showError($("#security_email_text"), rss.error_70001102_2);
                } else if (data.errorCode == "70001104") {
                    showError($("#security_email_text"), rss.error_70001104_3);
                } else if (data.errorCode == "70001201" || data.errorCode == "70002008") {
                    showError($("#security_email_text"), rss.error_70001201_2);
                } else if (data.errorCode == "70001401") {
                    showError($("#security_email_text"), rss.error_70001401);
                } else if (data.errorCode == "70002001") {
                    showError($("#security_email_text"), rss.error_70002001);
                } else if (data.errorCode == "70002018") {
                    showError($("#security_email_text"), rss.error_70002018);
                } else if (data.errorCode == "70002019") {
                    showError($("#security_email_text"), rss.error_70002019);
                } else {
                    showError($("#security_email_text"), rss.emailActivedFailed);
                }

            }
        }, function(data) {
            showError($("#verifyEmailTips"), rss.emailActivedFailed);
        }, true, "json");

    }
    
    function openPhoneDialog(oldAccObj, dialogTitle, btnTxt, opType) {
        if (!oldAccObj) {
            return;
        }

        var htmlStr = '<div id="oldAccObj"><div id="bindPhoneDialog"><div id="countryCodeDiv" class="sdrop"></div>';
        htmlStr += '<div id="newUserAccDiv" class="dinput"><input type="text" id="newUserAccount" placeholder="' + rss.phoneNumber + '"></div><p id="phone_error_info"></p>';
        htmlStr += '<div id="getPhoneAuthCodeBtn" intervaltime="60" class="dbtn2 sbtn r"><span>' + rss.getAuthCode + '</span><div id="authCodeError"></div></div>';
        htmlStr += '<div class="dinput sinput"><input type="text" id="newAuthCode" placeholder="' + rss.smsAuthCode + '"></div><p id="authCode_error_info"></p></div>';
        htmlStr += '</div>';
        var items = [];
        if (localInfo.countryCodes) {
        	localInfo.countryCodes=localInfo.countryCodes.substring(0,localInfo.countryCodes.length-1);
            var contrysArr = localInfo.countryCodes.split(",");
            $.each(contrysArr, function(n, value) {
                var temp = value.split("(");
                var key = temp[0];
                key = key.replace("+", "00");
                var item = {
                    value : key,
                    label : value
                };
                items.push(item);
            });

        }
        var option = {
            title : dialogTitle,
            btnRight : {
                text : btnTxt,
                fn : function() {
                    var self = this;
                    if (!ec.form.validator($("#bindPhoneDialog"), true)) {
                        return false;
                    }
                    var countryCode = $("#countryCodeDiv input").val();
                    var newUserAccount = $("#newUserAccount").val();
                    newUserAccount = countryCode + newUserAccount;
                    var newAccObj = {
                        newAccountType : 2,
                        newUserAccount : newUserAccount,
                        newAuthCode : $("#newAuthCode").val()
                    };
                    self.disabled();
                    setPhoneEmail(oldAccObj, newAccObj, opType, function() {
                        self.hide();
                    });
                }
            },
            btnLeft : {
                text : rss.cancel_btn,
                fn : function() {
                }
            },
            html : htmlStr,
            beforeAction : function() {
                $('#countryCodeDiv').DropList({
                    items : items,
                    defaultValue : localInfo.default_country_code,
                    onChange : function(key, value) {
                        var temp = value.split("(");
                        if (temp.length > 1) {
                            $("#countryCode").val(temp[0]);
                        	checkLengthByCountry(temp[0], $("#newUserAccount"), "#phone_error_info", rss.validatorPhone);
                        }
                        	
                    }
                });
                var self = this;
                self.disabled();
                
                $("#newUserAccount").on("keyup change", function() {
                    if ($("#newUserAccount").val().trim() != "" && $("#newAuthCode").val().trim() != "") {
                        self.enable();
                    } else {
                        self.disabled();
                    }
                });
                
                $("#newAuthCode").on("keyup change", function() {
                    if ($("#newUserAccount").val().trim() != "" && $("#newAuthCode").val().trim() != "") {
                        self.enable();
                    } else {
                        self.disabled();
                    }
                });
                
                $("#getPhoneAuthCodeBtn").click(function(e) {
                    if (!ec.form.validator($("#countryCodeDiv"), true) || !ec.form.validator($("#newUserAccDiv"), true)) {
                        return false;
                    }
                    if ($("#getPhoneAuthCodeBtn").attr("disabled")) {
                        return false;
                    }
                    var countryCode = $("#countryCodeDiv input").val();
                    var newUserAccount = $("#newUserAccount").val();
                    newUserAccount = countryCode + newUserAccount;
                    isExistAccount(newUserAccount, function() {
                        var param = {
                            userID : "",
                            account : newUserAccount,
                            phoneOrEmail : newUserAccount,
                            accountType : 2,
                            authCodebtn : $("#getPhoneAuthCodeBtn"),
                            reqType : 3
                        };
                        getAuthCode(param);
                    });
                });
            }
        };
        $("<div>").Dialog(option).Dialog('show');
        $("#oldAccObj").data("oldAccObj", oldAccObj);
    	checkLengthByCountry($("#countryCodeDiv input").val(), $("#newUserAccount"), "#phone_error_info", rss.validatorPhone);
        checkPhone();
        checkAuthCodeInput($("#newAuthCode"), "#authCode_error_info");

    }

    function openEmailDialog(oldAccObj, dialogTitle, btnTxt, opType) {
        var htmlStr = '<div id="oldAccObj"><div id="bindEmailDialog"><div id="newEmailDiv" class="dinput"><input type="text" id="newEmailAccount" placeholder="' + rss.inputNewSecEmail + '"><p id="email_error_info"></p></div>';
        htmlStr += '<div id="getEmailAuthCodeBtn" intervaltime="60" class="dbtn2 sbtn r"><span>' + rss.getAuthCode + '</span><div id="authCodeError"></div></div>';
        htmlStr += '<div class="dinput sinput"><input type="text" id="newAuthCode" placeholder="' + rss.emailAuthCode + '"></div></div>';
        htmlStr += '<p id="authCode_error_info"></p>';
        htmlStr += '</div>';
        var option = {
            title : dialogTitle,
            btnRight : {
                text : btnTxt,
                fn : function() {
                    var self = this;
                    if (!ec.form.validator($("#bindEmailDialog"), true)) {
                        return false;
                    }

                    var newEmailAccount = $("#newEmailAccount").val();

                    var newAccObj = {
                        newAccountType : 1,
                        newUserAccount : newEmailAccount,
                        newAuthCode : $("#newAuthCode").val()
                    };
                    self.disabled();
                    setPhoneEmail(oldAccObj, newAccObj, opType, function() {
                        self.hide();
                    });
                }
            },
            btnLeft : {
                text : rss.cancel_btn,
                fn : function() {
                }
            },
            html : htmlStr,
            beforeAction : function() {
                var self = this;
                self.disabled();
                $("#newEmailAccount").on("keyup change", function() {
                    if ($("#newEmailAccount").val().trim() != "" && $("#newAuthCode").val().trim() != "") {
                        self.enable();
                    } else {
                        self.disabled();
                    }
                });
                $("#newAuthCode").on("keyup change", function() {
                    if ($("#newEmailAccount").val().trim() != "" && $("#newAuthCode").val().trim() != "") {
                        self.enable();
                    } else {
                        self.disabled();
                    }
                });
                $("#getEmailAuthCodeBtn").click(function(e) {
                    if (!ec.form.validator($("#newEmailDiv"), true)) {
                        return false;
                    }
                    if ($("#getEmailAuthCodeBtn").attr("disabled")) {
                        return false;
                    }
                    var newUserAccount = $("#newEmailAccount").val();
                    isExistAccount(newUserAccount, function(retVal) {
                        var param = {
                            userID : "",
                            account : newUserAccount,
                            phoneOrEmail : newUserAccount,
                            accountType : 1,
                            authCodebtn : $("#getEmailAuthCodeBtn"),
                            reqType : 3
                        };
                        getAuthCode(param);
                    });
                });
            }
        };
        $("<div>").Dialog(option).Dialog('show');
        
        $("#oldAccObj").data("oldAccObj", oldAccObj);
        checkEmail();
        checkAuthCodeInput($("#newAuthCode"), "#authCode_error_info");
    }

    function showSuccessTipDialog(tip1, tip2, imgPath, callbackFn) {
        var htmlStr = '<div class="dtit">' + tip1 + '</div>';
        htmlStr += '<div class="dcent">';
        htmlStr += '<div class="center">';
        htmlStr += '<img class="dimg" src="' + imgPath + '">';
        htmlStr += '<p class="inptips2">' + tip2 + '</p>';
        htmlStr += '</div>';
        htmlStr += '</div>';

        var option = {
            title : "",
            btnRight : {
                text : rss.close_btn,
                fn : function() {
                    this.hide();
                    callbackFn();
                }
            },
            btnLeft : false,
            html : htmlStr
        };

        $("<div>").Dialog(option).Dialog('show');
    }

    function showUserNoticeDialog(type) {
    	var items = type.split('_');
    	
    	var index;
    	if (items && items.length >= 2)
    	{
    		index = "_" + items[1];
    	}
    	else
    	{
    		index = "";
    	}
        var htmlStr = '<div class="dcent">';
        /*htmlStr += '<p class="inptips6" style="font-weight:bold">' + rss.userInstructions + '</p>';
        htmlStr += '</br>';*/
        var title = "";
        title=rss.uc_note;
        
        var rightBtn="";
        
        if (type.startWith('unbindEmail')) {
            htmlStr += '<p class="inptips2">' + rss.unbindSecEmailTip + '</p>';
//            title = rss.title_unbind_account;
            rightBtn=rss.unbind_btn;
        } else if (type.startWith('unbindPhone')) {
            htmlStr += '<p class="inptips2">' + rss.unbindSecPhoneTip + '</p>';
//            title = rss.title_unbind_account;
            rightBtn=rss.unbind_btn;
        } else if (type.startWith('changeEmail') ) {
            htmlStr += '<p class="inptips2">' + rss.changeSecEmailTip + '</p>';
//            title = rss.title_change_account;
            rightBtn=rss.change_btn;
        }
        else if(type.startWith('changePhone'))
        	{
        	htmlStr += '<p class="inptips2">' + rss.changeSecPhoneTip + '</p>';
//          title = rss.title_change_account;
             rightBtn=rss.change_btn;
        	}
        	

//        htmlStr += '<p id="agreeBtn" class="inptips2 mtop"><b data-value="false" class="tick off"></b>' + rss.IAgree + '</p>';
        htmlStr += '</div>';
        var option = {
            title : title,
            btnLeft : {
                text : rss.cancel_btn,
                fn : function() {
                    this.hide();
                }
            },
            btnRight : {
                text : rightBtn,
                fn : function() {
                   
//                    if ($("#agreeBtn").has('.off').length == 1) {
//                        return false;
//                    }
                    this.hide();

                    if (type.startWith('unbindEmail')) {
                        var param = {
                            desc : rss.secAccountUnbindTip,
                            lBtnTxt : rss.cancel_btn,
                            rBtnTxt : rss.unbind_btn,
                            queryCond : $("#emailVal" + index).text().trim(),
                            optType : "unbind",
                            callbackFn : unbindAccount
                        };
                        openAuthenDialog(param);
                    } else if (type.startWith('unbindPhone')) {
                        var param = {
                            desc : rss.secAccountUnbindTip,
                            lBtnTxt : rss.cancel_btn,
                            rBtnTxt : rss.unbind_btn,
                            queryCond : $("#phoneVal" + index).text().trim(),
                            optType : "unbind",
                            callbackFn : unbindAccount
                        };
                        openAuthenDialog(param);
                    } else if (type.startWith('changeEmail')) {
                        var param = {
                            desc : rss.changeSecAccountNeedAuth,
                            lBtnTxt : rss.cancel_btn,
                            rBtnTxt : rss.next_btn,
                            queryCond : loginUserName,
                            optType : "change",
                            callbackFn : changeEmail
                        };
                        openAuthenDialog(param);
                    } else if (type.startWith('changePhone')) {
                        var param = {
                            desc : rss.changeSecAccountNeedAuth,
                            lBtnTxt : rss.cancel_btn,
                            rBtnTxt : rss.next_btn,
                            queryCond : loginUserName,
                            optType : "change",
                            callbackFn : changePhone
                        };
                        openAuthenDialog(param);
                    }

                }
            },
            html : htmlStr,
            beforeAction : function() {
//                var self = this;
//                self.disabled();
//                $(".tick").on("click", function() {
//                    $(this).data("value") == true ? $(this).trigger("turnoff") : $(this).trigger("turnon");
//                }).on("turnon", function() {
//                    $(this).removeClass("off");
//                    $(this).data("value", true);
//                    $(this).trigger("change", [true]);
//                    self.enable();
//                }).on("turnoff", function() {
//                    $(this).addClass("off");
//                    $(this).data("value", false);
//                    $(this).trigger("change", [false]);
//                    self.disabled();
//                });
            }
        };

        $("<div>").Dialog(option).Dialog('show');
    }

    function showDialog($ele) {
        $ele.addClass("show");
        $ele.removeClass("hidden");
    }

    function hideDialog($ele) {
        $ele.addClass("hidden");
        $ele.removeClass("show");
    }

    function checkCountryCode() {
        var countryCode = $("#countryCode");
        ec.form.validator.bind(countryCode, {
            type : ["require"],
            trim : false,
            validOnChange : true,
            msg_ct : "#countrycode_error_info",
            msg : {
                require : rss.chooseCountryCodeTip
            }
        });
    }
    
    function checkLengthByCountry(countryCode, $username, $errorDiv, errorMsg) {
    	$username.unbind("change");
    	$username.removeClass("cas_error");
        
    	if(countryCode.indexOf("+") > -1) {
    		countryCode = countryCode.replace("+", "00");
    	}
    	if(countryCode == "001") { //美国
    		ec.form.validator.bind($username, {
    			type : ["length"],
    			trim : false,
    			validOnChange : true,
    			min : 10,
    			max : 10,
    			msg_ct : $errorDiv,
    			msg : {
    				length : errorMsg
    			}
    		});
    	}
    }

    function checkPhone() {
        var newUserAccount = $("#newUserAccount");
        ec.form.validator.bind(newUserAccount, {
            type : ["require", "phoneNumber"],
            trim : false,
            validOnChange : true,
            msg_ct : "#phone_error_info",
            msg : {
                require : rss.validatorPhoneRequire,
                phoneNumber : rss.validatorPhone
            }
        });
    }
    
    function checkAuthCodeBtnState(ele, text) {
		var authEle = ele.find("[act='getVerificationCode']");
		var disabled = authEle.attr("disabled");
		if (disabled) {
			return false;
		}
		return true;
	}

    function checkEmail() {
        var newEmailAccount = $("#newEmailAccount");
        ec.form.validator.bind(newEmailAccount, {
            type : ["require", "email"],
            trim : false,
            validOnChange : true,
            msg_ct : "#email_error_info",
            msg : {
                require : rss.validatorEmailRequire,
                email : rss.validatorEmail

            }
        });
    }
    
	function authCodeCountDown(ele, text) {
		var authEle = ele.find("[act='getVerificationCode']");
		var disabled = authEle.attr("disabled");
		if (disabled) {
			return false;
		}
		authEle.addClass("auth_code_grey");
		jsInnerTimeout(authEle, text);
		return true;
	}
    
    /* 获取验证码,此处添加此函数仅仅为了支撑未激活手机号码 */
	function getAuthCodeForUnSMS(accountType, account, type, callback, mobilePhone, mobilePhoneType) {
		if (!mobilePhone)
		{
			mobilePhone = account;
		}
		if(!mobilePhoneType)
		{
			mobilePhoneType = accountType;
		}
		
		var params = {};
		var method = "";
		var infoElement = $("#get_authcode_error_info");
		if (mobilePhoneType == 1 || mobilePhoneType == 5) {
			method = "getEMailAuthCode";
			params = {
	 			email: account,
	 			emailReqType: type,
	 			accountType: accountType,
	 			reqClientType: reqClientType,
 				pageToken: localInfo.pageToken,
 				languageCode:localInfo.lang
	 		};
		} else if (mobilePhoneType == 2 || mobilePhoneType == 6) {
			method = "getSMSAuthCode";
			params = {
 				accountType: accountType,
 				userAccount: account,
 				reqClientType: reqClientType,
 				mobilePhone: mobilePhone,
 				smsReqType:type,
 				pageToken: localInfo.pageToken,
 				languageCode:localInfo.lang
 			};
		}
		
 		ajaxHandler(method, params, function(data) {
 			if (data && data.isSuccess == 1) {
 				if (method == "getSMSAuthCode") {
 					showSuccess(infoElement, rss.phoneMegHasSendTo.format(getExpressPhone(mobilePhone)));
 				} else if (method == "getEMailAuthCode") {
 					showSuccess(infoElement, rss.emialHasSendTo.format(account));
 					$(".userAccount").html(account);
 				}
 			} else {
 				switch(data.errorCode) {
	 				case "10000001":
	 				case "10000002":
	 				case "10000003":
	 				case "70001201": {
	 					showError(infoElement, rss.error_10000001);
	 					break;
	 				}
	 				case "70001401": {
	 					showError(infoElement, rss.error_70001401);
	 					break;
	 				}
	 				case "70002002": {
	 					showError(infoElement, rss.error_needcountrycode);
	 					break;
	 				}
	 				case "70002001": {
	 					showError(infoElement, rss.error_70002001);
	 					break;
	 				}
	 				case "70002028": {
	 					showError(infoElement, rss.error_70002028);
	 					break;
	 				}
	 				case "70002046": {
	 					showError(infoElement, rss.error_70002046);
	 					break;
	 				}
	 				case "70002030": {
	 					showError(infoElement, rss.error_70002030);
	 					break;
	 				}
	 				case "70001102": {
	 					if (method == "getEMailAuthCode") {
	 						showError(infoElement, rss.error_70001102_0);
	 					} else if (method == "getSMSAuthCode") {
	 						showError(infoElement, rss.error_70001102_1);
	 					}
	 					break;
	 				}
	 				case "70001104": {
	 					if (method == "getEMailAuthCode") {
	 						showError(infoElement, rss.error_70001104_0, "left");
	 					} else if (method == "getSMSAuthCode") {
	 						showError(infoElement, rss.error_70001104_1, "left");
	 					}
	 					break;
	 				}
	 				case "10000004": {
	 					showError(infoElement, rss.error_10000004);
	 					break;
	 				}
	 				case "10000002": {
	 					showError(infoElement, rss.error_10000002);
	 					break;
	 				}
	 				default: {
	 					showError(infoElement, rss.get_authcode_error);
	 					break;
	 				}
 				}
 			}
 			
 			if (callback) {
				callback(data.isSuccess == 1 ? true : false);
			}
 		}, function(){}, true, "json");
 	}
	
	function showTipDialog(title, btnText, content, callback) {
		$("<div>").Dialog({
			title: title,
			btnRight: {
				text: btnText,
				fn: function() {
					this.hide();
					if (typeof callback == "function") {
						callback();
					}
				}
			},
			btnLeft: false,
			html: '<div class="center">' +
				'<img class="dimg" src="'+localInfo.successImgPath+'">' +
				'<p class="inptips2">' + content + '</p>' +
				'</div>'
		}).Dialog("show");
	}
	
    
    
    /* 保存帐号信息 */
/*    function initUserInfo(data) {
    	userAcctInfoData = data;
    	userInfo.oldAccountType = data.userAcctInfoList[0].accountType;
    	userInfo.oldUserAccount = data.userAcctInfoList[0].userAccount;
    }*/
    
    function getUserAccInfo(userAccount, callback) {
    	var params = {
    		userAccount: userAccount,
    		reqClientType: localInfo.reqClientType,
    		isGetAll: "3",
    		pageToken: localInfo.pageToken
    	};
    	ajaxHandler("getUserAccInfo", params, function(data) {
    			if (data && data.isSuccess == 1) {
    				callback(data);
    			} else {
    				 var errorCode = data.errorCode;
    				 if(errorCode == "10000001") 
    				 {
    					showError($("#delUser"), rss.error_10000001_3);
    				 }else if(errorCode == "10000004") 
    				 {
    					 showError($("#delUser"), rss.error_10000004);
    				 }else if(errorCode == "10000002") 
    				 {
    					 showError($("#delUser"), rss.error_10000002);
    				 }
    				 else 
    				 {
    					 showError($("#delUser"), rss.error_10000001_3);
    				 }
    			}
    		}, function(){}, true, "json");
    }
    
    function mobileValidator() {
		ec.form.validator.register("phoneNumber", function(b_val, a) {
			var currentCountryCode = $("#countryCodeDiv > input").val();
			var reg = "";
			if (currentCountryCode && currentCountryCode == "0086") {
				reg = /^(1[34578])[0-9]{9}$|(^(\+|00)852[9865])[0-9]{7}$/;
			} else if(currentCountryCode == "001" || currentCountryCode == "+1"){
				reg = /^[0-9]{10}$/;
			} else {
				reg = /^[0-9]{5,15}$/;
			}
			return reg.test(b_val) ? true : false;
		});
	}
})(jQuery, window);
